﻿using ANX.Framework.Graphics;
using Core.Model.Chunks;
using Core.Model.Types;

namespace ANXGame.Model
{
    public class XnaChunk : Chunk
    {
        public IndexBuffer IndexBuffer;
        public VertexBuffer VertexBuffer;

        public XnaChunk(VectorIndex index)
            : base(index)
        {
        }

        public void DrawChunk(GraphicsDevice graphics, Effect effect)
        {
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                
                graphics.SetVertexBuffer(VertexBuffer);
                graphics.Indices = IndexBuffer;
                graphics.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, VertexCount, 0, PrimitivesCount);
            }
        }
    }
}